package com.example.mine_platform.mapper;

import com.example.mine_platform.pojo.entities.Scheduling;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.time.LocalDateTime;
import java.util.List;

public interface SchedulingMapper extends Mapper<Scheduling> {
    @Select("select busy_time from scheduling where user_id=#{userId} AND deleted = 0")
    List<String> getOne(@Param("userId")int userId);
    @Select("select busy_time from scheduling where deleted != 1")
    List<String> getAll();
    @Insert("insert into scheduling(user_id,busy_time,create_time,update_time,deleted) values( #{userId}, #{busyTime,jdbcType=TIMESTAMP},#{now,jdbcType=TIMESTAMP},#{update,jdbcType=TIMESTAMP},#{deleted} )")
    void add(@Param("userId")int userId, @Param("busyTime") LocalDateTime busyTime, @Param("now") LocalDateTime now, @Param("update") LocalDateTime update, @Param("deleted") int deleted);

    @Update("update scheduling set deleted = 1 where user_id = #{userId} AND busy_time = #{dateTime,jdbcType=TIMESTAMP}")
    void updatewithdeleted(@Param("userId")int userId,@Param("dateTime")LocalDateTime dateTime);
}